RUMS-5681: Add support for Android heatmaps - #1341
Conversation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: f6878d3 | Docs | Datadog PR Page | Give us feedback! |
662fe52 to
b81ec1d
Compare
marco-saia-datadog
left a comment
There was a problem hiding this comment.
LGTM 👍 Good to go as soon as we add test coverage in our E2E test matrix, so that we can verify these changes across different versions of React Native, old vs new architecture, hermes vs non-hermes etc.
b81ec1d to
9720abc
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds Android-side heatmap support for the React Native SDK by wiring a new heatmap touch-resolution pipeline into RUM TAP actions and exposing an enableHeatmaps toggle via Session Replay enablement.
Changes:
- Add
HeatmapTouchResolver+HeatmapActionHandlerto compute and attachCrossPlatformHeatmapActionDatafor eligible TAP actions. - Propagate
enableHeatmapsinto Android Session Replay configuration and store a global heatmap-enabled flag used by RUM. - Add/extend Android unit tests to cover heatmap eligibility, fallback behavior, and resolver output; update the example app to enable Session Replay with heatmaps.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt | Enables heatmaps in SR config and toggles the global heatmaps-enabled flag. |
| packages/react-native-session-replay/android/src/test/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementationTest.kt | Adds tests validating enableHeatmaps propagation and global flag behavior. |
| packages/core/android/src/main/kotlin/com/datadog/reactnative/HeatmapTouchResolver.kt | New resolver that turns a React tag + coordinates into CrossPlatformHeatmapActionData. |
| packages/core/android/src/main/kotlin/com/datadog/reactnative/HeatmapActionHandler.kt | New eligibility + attachment logic that dispatches view work on the main thread and calls addActionWithHeatmap. |
| packages/core/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt | Routes TAP actions through heatmap handling, resolving the JS promise before dispatching heatmap work. |
| packages/core/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt | Wires HeatmapActionHandler/HeatmapTouchResolver using UIManagerHelper view resolution (old arch). |
| packages/core/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt | Wires HeatmapActionHandler/HeatmapTouchResolver using UIManagerHelper + ViewUtil UIManager type (new arch). |
| packages/core/android/src/test/kotlin/com/datadog/reactnative/HeatmapTouchResolverTest.kt | New unit test suite for heatmap touch resolution and element path generation. |
| packages/core/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt | Adds tests for heatmap gating, internal proxy path, fallback behavior, and promise ordering. |
| example/src/ddUtils.tsx | Removes now-inlined initialization helper. |
| example/src/App.tsx | Inlines initialization logic and enables Session Replay with enableHeatmaps: true. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/react-native-session-replay/android/src/main/kotlin/com/datadog/reactnative/sessionreplay/DdSessionReplayImplementation.kt:67
- If
sessionReplayProvider().enable(...)throws,HeatmapActionHandler.heatmapsEnabledis not updated. Because this flag is global, a previous successfulenable(..., enableHeatmaps = true, ...)could leave heatmap tracking enabled even when a subsequentenable(..., enableHeatmaps = false, ...)attempt fails. Consider resetting the flag before calling into the provider, and only setting it to the requested value after a successful enable.
sessionReplayProvider().enable(configuration.build(), sdkCore)
HeatmapActionHandler.heatmapsEnabled = enableHeatmaps
promise.resolve(null)
What does this PR do?
Adds heatmap support for Android RN
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)